home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Mesa-2.2 / src / polygon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-13  |  3.6 KB  |  147 lines

  1. /* $Id: polygon.c,v 1.3 1996/10/11 03:44:58 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.0
  6.  * Copyright (C) 1995-1996  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: polygon.c,v $
  26.  * Revision 1.3  1996/10/11 03:44:58  brianp
  27.  * removed Polygon.OffsetBias
  28.  *
  29.  * Revision 1.2  1996/09/26 22:48:40  brianp
  30.  * set NEW_RASTER_OPS flag in gl_PolygonStipple() if stippling enabled
  31.  *
  32.  * Revision 1.1  1996/09/13 01:38:16  brianp
  33.  * Initial revision
  34.  *
  35.  */
  36.  
  37.  
  38. #include <assert.h>
  39. #include <stdlib.h>
  40. #include <string.h>
  41. #include "context.h"
  42. #include "macros.h"
  43. #include "polygon.h"
  44. #include "types.h"
  45.  
  46.  
  47.  
  48. void gl_CullFace( GLcontext *ctx, GLenum mode )
  49. {
  50.    if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) {
  51.       gl_error( ctx, GL_INVALID_ENUM, "glCullFace" );
  52.       return;
  53.    }
  54.    if (INSIDE_BEGIN_END(ctx)) {
  55.       gl_error( ctx, GL_INVALID_OPERATION, "glCullFace" );
  56.       return;
  57.    }
  58.    ctx->Polygon.CullFaceMode = mode;
  59.    ctx->NewState |= NEW_RASTER_OPS;
  60. }
  61.  
  62.  
  63.  
  64. void gl_FrontFace( GLcontext *ctx, GLenum mode )
  65. {
  66.    if (INSIDE_BEGIN_END(ctx)) {
  67.       gl_error( ctx, GL_INVALID_OPERATION, "glFrontFace" );
  68.       return;
  69.    }
  70.    if (mode!=GL_CW && mode!=GL_CCW) {
  71.       gl_error( ctx, GL_INVALID_ENUM, "glFrontFace" );
  72.       return;
  73.    }
  74.    ctx->Polygon.FrontFace = mode;
  75. }
  76.  
  77.  
  78.  
  79. void gl_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
  80. {
  81.    if (INSIDE_BEGIN_END(ctx)) {
  82.       gl_error( ctx, GL_INVALID_OPERATION, "glPolygonMode" );
  83.       return;
  84.    }
  85.    if (face!=GL_FRONT && face!=GL_BACK && face!=GL_FRONT_AND_BACK) {
  86.       gl_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
  87.       return;
  88.    }
  89.    else if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) {
  90.       gl_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" );
  91.       return;
  92.    }
  93.  
  94.    if (face==GL_FRONT || face==GL_FRONT_AND_BACK) {
  95.       ctx->Polygon.FrontMode = mode;
  96.    }
  97.    if (face==GL_BACK || face==GL_FRONT_AND_BACK) {
  98.       ctx->Polygon.BackMode = mode;
  99.    }
  100.  
  101.    /* Compute a handy "shortcut" value: */
  102.    if (ctx->Polygon.FrontMode!=GL_FILL || ctx->Polygon.BackMode!=GL_FILL) {
  103.       ctx->Polygon.Unfilled = GL_TRUE;
  104.    }
  105.    else {
  106.       ctx->Polygon.Unfilled = GL_FALSE;
  107.    }
  108.  
  109.    ctx->NewState |= NEW_RASTER_OPS;
  110. }
  111.  
  112.  
  113.  
  114. void gl_PolygonStipple( GLcontext *ctx, const GLubyte *mask )
  115. {
  116.    /* TODO:  bit twiddling, unpacking */
  117.    if (INSIDE_BEGIN_END(ctx)) {
  118.       gl_error( ctx, GL_INVALID_OPERATION, "glPolygonStipple" );
  119.       return;
  120.    }
  121.    MEMCPY( ctx->PolygonStipple, mask, 32*4 );
  122.    if (ctx->Polygon.StippleFlag) {
  123.       ctx->NewState |= NEW_RASTER_OPS;
  124.    }
  125. }
  126.  
  127.  
  128.  
  129. void gl_GetPolygonStipple( GLcontext *ctx, GLubyte *mask )
  130. {
  131.    /* TODO */
  132. }
  133.  
  134.  
  135.  
  136. void gl_PolygonOffset( GLcontext *ctx,
  137.                        GLfloat factor, GLfloat units )
  138. {
  139.    if (INSIDE_BEGIN_END(ctx)) {
  140.       gl_error( ctx, GL_INVALID_OPERATION, "glPolygonOffset" );
  141.       return;
  142.    }
  143.    ctx->Polygon.OffsetFactor = factor;
  144.    ctx->Polygon.OffsetUnits = units;
  145. }
  146.  
  147.